package com.ruoyi.notice.factory;

import com.ruoyi.common.utils.ApplicationContextUtil;
import com.ruoyi.notice.enums.MessageTypeEnum;
import com.ruoyi.notice.service.IHandleMessageService;
import com.ruoyi.notice.service.message.BillEnterWarningHandleMessageService;

import java.util.HashMap;
import java.util.Map;

public class HandleMsgFactory {

    private static Map<String, Class<? extends IHandleMessageService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(MessageTypeEnum.BILL_ENTER_WARNING.getValue(), BillEnterWarningHandleMessageService.class);
    }

    public static IHandleMessageService getService(String type){
        if (serviceMap.containsKey(type)){
            Class<? extends IHandleMessageService> aClass = serviceMap.get(type);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }
}
